package com.xbe.equipment.service.impl;

import com.xbe.common.annotation.DataScope;
import com.xbe.common.core.text.Convert;
import com.xbe.common.utils.DateUtils;
import com.xbe.equipment.domain.Equipment;
import com.xbe.equipment.mapper.EquipmentMapper;
import com.xbe.equipment.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备管理Service业务层处理
 *
 * @author liuzhiting
 * @date 2020-06-19
 */
@Service
public class EquipmentServiceImpl implements IEquipmentService
{
    @Autowired
    private EquipmentMapper equipmentMapper;

    /**
     * 查询设备管理
     *
     * @param id 设备管理ID
     * @return 设备管理
     */
    @Override
    public Equipment selectEquipmentById(Long id)
    {
        return equipmentMapper.selectEquipmentById(id);
    }

    @Override
    public Equipment selectEquipmentBySim(String sim)
    {
        return equipmentMapper.selectEquipmentBySim(sim);
    }

    /**
     * 查询设备管理列表
     *
     * @param equipment 设备管理
     * @return 设备管理
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<Equipment> selectEquipmentList(Equipment equipment)
    {
        return equipmentMapper.selectEquipmentList(equipment);
    }

    /**
     * 新增设备管理
     *
     * @param equipment 设备管理
     * @return 结果
     */
    @Override
    public int insertEquipment(Equipment equipment)
    {
        return equipmentMapper.insertEquipment(equipment);
    }

    /**
     * 修改设备管理
     *
     * @param equipment 设备管理
     * @return 结果
     */
    @Override
    public int updateEquipment(Equipment equipment)
    {
        equipment.setUpdateTime(DateUtils.getNowDate());
        return equipmentMapper.updateEquipment(equipment);
    }

    @Override
    public int updateEquipmentSetRoadInfoAsNull(Equipment equipment)
    {
        equipment.setUpdateTime(DateUtils.getNowDate());
        return equipmentMapper.updateEquipmentSetRoadInfoAsNull(equipment);
    }

    @Override
    public int updateEquipmentBySim(Equipment equipment)
    {
        equipment.setUpdateTime(DateUtils.getNowDate());
        return equipmentMapper.updateEquipmentBySim(equipment);
    }

    /**
     * 删除设备管理对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteEquipmentByIds(String ids)
    {
        return equipmentMapper.deleteEquipmentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除设备管理信息
     *
     * @param id 设备管理ID
     * @return 结果
     */
    @Override
    public int deleteEquipmentById(Long id)
    {
        return equipmentMapper.deleteEquipmentById(id);
    }

    @Override
    public List selectEquipmentByRoadId(Long roadId)
    {
        return equipmentMapper.selectEquipmentByRoadId(roadId);
    }

    @Override
    public List<Equipment> getSims()
    {
        return equipmentMapper.getSims();
    }

    @Override
    public List<Equipment> selectEquipmentListNoDataScope(Equipment equipment)
    {
        return equipmentMapper.selectEquipmentListNoDataScope(equipment);
    }

    @Override
    public void updateEquipmentBySim1(Equipment equipment)
    {
        equipmentMapper.updateEquipmentBySim1(equipment);
    }

    @Override
    public List<Equipment> selectEquipmentListAll(Equipment equipment)
    {
        return equipmentMapper.selectEquipmentListAll(equipment);
    }
}
